const path = require('path')

const resolve = dir => {
  return path.join(__dirname, dir)
}
// 需要将它改为'/my-app/'
// 服务器中的文件名称  process.env.VUE_APP_MODE === 'prod' ? '/' :
const BASE_URL = '/CUS/'

module.exports = {
  // publicPath: '/CUS/',
  outputDir: 'dist',
  // 基本接口路径
  publicPath: BASE_URL,
  baseUrl: BASE_URL,
  // 如果你不需要使用eslint，把lintOnSave设为false即可
  lintOnSave: false,
  assetsDir: "static",
  // 路径设置
  chainWebpack: config => {
    config.resolve.alias
      .set('@', resolve('src'))
      .set('_c', resolve('src/components'));
    config.optimization.splitChunks({
      chunks: 'all',
      cacheGroups: {
        libs: {
          name: 'admin-plus-libs',
          test: /[\\/]node_modules[\\/]/,
          priority: 10,
          chunks: 'initial'
        },
        elementUI: {
          name: 'admin-plus-element-ui',
          priority: 20,
          test: /[\\/]node_modules[\\/]_?element-ui(.*)/
        },
        viewDesign: {
          name: 'view-design',
          priority: 20,
          test: /[\\/]node_modules[\\/]_?view-design(.*)/
        }
      }
    });
  },
  // 设为false打包时不生成.map文件
  productionSourceMap: false,
  // 这里写你调用接口的基础路径，来解决跨域，如果设置了代理，那你本地开发环境的axios的baseUrl要写为 '' ，即空字符串
  devServer: {
    open: process.platform === 'development',
    host: '0.0.0.0',
    port: 8081,
    https: false,
    hotOnly: false,
    // 查阅 https://github.com/vuejs/vue-doc-zh-cn/vue-cli/cli-service.md#配置代理
    proxy: null,
  /*{
      '/api': {
        target: 'http://192.168.81.105/:8080/api',
        changeOrigin: true,
        pathRewrite: {'^/api': ''}
      }
    },*/ // string | Object
    before: app => {
      // `app` 是一个 express 实例
    },
    disableHostCheck: true
  }

}
